package com.sise.thread;

import com.sise.thread.lab01.Producer;

/**
 * 作者：idea
 * 日期：2018/6/29
 * 描述：
 */
public class Yield {
    public static void main(String[] args) {
        Thread producer=new Producers();
        Thread consumer=new Consumer();
        producer.setPriority(Thread.MIN_PRIORITY);
        consumer.setPriority(Thread.MAX_PRIORITY);
        producer.start();
        consumer.start();

    }


}
class Producers extends Thread{
    public void run(){
        for(int j=0;j<10;j++){
            System.out.println("Producers"+j);
            Thread.yield();  //会让步给同等级的线程执行
        }
    }
}

class Consumer extends Thread{
    public void run(){
        for(int k=0;k<10;k++){
            System.out.println("Consumer"+k);
            Thread.yield(); //会让步给同等级的线程执行
        }
    }
}
